<include file=".:Common:header" />
<script language="javascript">
/*$(function(){
	$('#datagrid').datagrid({
		toolbar:[{
			id:'btnadd',
			text:'新增应用',
			iconCls:'icon-add',
			handler:function(){
				toUrl('{:U("Apps/add")}');
			}
		},'-',
		{
			text:'编辑应用',
			iconCls:'icon-edit',
			handler:function(){
				var row = $('#datagrid').datagrid('getSelected');
				if (row){
					toUrl("{:U('Apps/edit')}&app_id="+row.app_id);
				}
			}
		},'-',{
			text:'删除应用',
			iconCls:'icon-remove',
			handler:function(){
				var row = $('#datagrid').datagrid('getSelected');
				if (row){
					$.messager.confirm('提示', '确定删除吗？', function(r){
					if (r){
						ajaxPost("{:U('Apps/remove')}", {'app_id': row.app_id}, function(d){
							if(d.status == 0){
								alertText(d.info, 'error');
							}else{
								$('#datagrid').datagrid('reload');
							}
						});
					}else return false;
					});	
				}
			}
		}]
	});
});*/
$(function(){
$('#datagrid').treegrid({
		title:'应用列表',
		width:'100%',
		rownumbers: true,
		animate:true,
		collapsible:true,
		url:'{:U("system/Apps/app_list")}&d='+Math.random(),
		idField:'app_id',
		treeField:'app_name',
		frozenColumns:[[
			{field:'app_id',title:'ID',width:30},
			{title:'应用名称',field:'app_name',width:150}
		]],
		columns:[[
			{field:'app_title',title:'应用标题',width:80},
			{field:'add_time',title:'添加时间',width:100},
			{field:'sort',title:'排序',width:80},
			{field:'remark',title:'备注',width:100},
			{field:'opt',title:'操作',width:180, formatter:function(v, r){
				return '<div class="opt"><a href="javascript:;" onclick="toEdit('+r.app_id+')" class="edit">编辑</a><a href="javascript:;" onclick="doDelete('+r.app_id+')" class="delete">删除</a></div>';}}
		]]
	});
});
/*修改*/
function toEdit(id){
	window.location.href='{:U("Apps/edit")}&app_id='+id;
}
/*删除*/
function doDelete(id){
alert(id);
	$.messager.confirm('提示', '确定删除该应用吗？', function(r){
		if (r){
			$.ajax({
				url : '{:U("system/Apps/remove")}',
				data : 'app_id='+id,
				dataType: 'json',
				success : function(d){
					if(d.status == 0){
						alertText(d.info, 'error');
					}else{
						$('#datagrid').treegrid('reload');
					}
				}
			});
		}
	});
}
</script>
<div class="wrapper clear">
	<div class="main">
		<if condition="!empty($button)">
		<div class="toolbar">
	        <h3>
		        <volist name="button" id="btn">
		        <a href="{$btn.href}" id="add1"  title="{$btn.text}">{$btn.text}</a>
		        </volist>
	        </h3>
				
				
				
		</div>
		</if>
		<div id="divarrowdown"><a href="#" id="expand"></a></div>	
		<div class="table_wrap">
			<div class="table_list">
				<table id="datagrid">
				</table>
			</div>
		</div>
			
	</div>
</div>	
<include file=".:Common:footer" />